﻿
using Hotel.DAL;
using Hotel.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Hotle.BLL
{
    public class ShopBLL
    {
        public ShopBLL(ShopDAL dal)
        {
            Dal = dal;
        }

        public ShopDAL Dal { get; }


        //添加
        public int ShopAdd(ShopModel shop)
        {
            var Snum = GetShopName(shop.Name);
            if (Snum > 0)
            {
                return -1;//有重复名称
            }
            var info = Dal.ShopAdd(shop);
            return info;
        }

        //查询 name
        public int GetShopName(string name)
        {
            return Dal.GetShopName(name);
        }
        /// <summary>
        /// 显示list
        /// </summary>
        /// <param name="toCount"></param>
        /// <param name="toPage"></param>
        /// <param name="name"></param>
        /// <param name="index"></param>
        /// <param name="size"></param>
        /// <returns></returns>

        public List<ShopModel> GetShopList(out int toCount, out int toPage, string? name, int index = 1, int size = 3)
        {
            return Dal.GetShopList(out toCount, out toPage, name, index, size);
        }


        /// <summary>
        /// 批量删除
        /// </summary>
        /// <param name="ids"多个ids字符串></param>
        /// <returns></returns>
        public int DelShopId(string ids)
        {
            var aa = Dal.DelShopId(ids);
            if (aa > 0)
            {
                return 1;//删除成功
            }
            else
            {
                return -1;//删除失败
            }
        }

        /// <summary>
        /// 批量修改状态
        /// </summary>
        /// <param name="ids"></param>
        /// <param name="steta"></param>
        /// <returns></returns>
        public int Upsteta(string ids, int steta)
        {
            int res = Dal.Upsteta(ids, steta);
            if (res > 0)
            {
                return 1;//修改成功
            }
            else
            {
                return -2;//修改失败
            }
        }




    }
}
